<?php /*a:3:{s:60:"/www/web/codecheck/application/backman/view/order/index.html";i:1594673389;s:55:"/www/web/codecheck/application/backman/view/layout.html";i:1594223536;s:52:"/www/web/codecheck/application/backman/view/nav.html";i:1594223536;}*/ ?>
<!DOCTYPE html>
<html class="admin-sm">
<head>
<meta charset="utf-8">
<title>平台管理中心</title>
<link rel="icon" sizes="32*32" href="/favicon.ico">
<link rel="stylesheet" type="text/css" href="/static/css/font.css">
<link rel="stylesheet" type="text/css" href="/static/css/admin.css">
<link rel="stylesheet" type="text/css" href="/static/iview/iview.css">
<link rel="stylesheet" type="text/css" href="/static/css/iconf/iconfont.css">
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/vue"></script>
<script type="text/javascript" src="/static/iview/iview.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/vue-resource@1.5.1"></script>
	<script src="/static/lib/assets/jquery-1.12.4.js"></script>
<script type="text/javascript" src="/static/js/do.js"></script>
<script src="/static/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/static/js/admin.js"></script>
<script type="text/javascript" src="/static/js/package.js" data-path="/static/js/" data-root="/<?php echo request()->controller(); ?>/"  data-src="/static/js/common"></script>
</head>
<body>
<div id="app"></div>
<div class="x-nav">
    <span class="layui-breadcrumb">
        <a href="<?php echo url('index/home'); ?>" onclick="xadmin.add_tab('<?php echo url('index/home'); ?>','总揽')">首页</a>
        <?php foreach($path as $vv): ?>
        <a><?php echo htmlentities($vv['name']); ?></a>
        <?php endforeach; ?>
    </span>
    <a class="layui-btn layui-btn-small layui-btn-normal" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新"> <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md12">
			<div class="layui-card">
				
<style>
    /* .layui-table-cell{
        display:table-cell;
        vertical-align: middle;
    } */
    .layui-table-cell {
        height: inherit;
    }
    .layui-table-cell a{
        margin: 5px 0;
    }
    .newOrderNum{
        width:90%;
        length-height:20px;
        font-size:16px;
    }
  </style>
<div class="layui-tab layui-tab-brief">
    <ul class="layui-tab-title">
        <li class="layui-this"><?php echo htmlentities($pathCurrent['name']); ?></li>
        <!--<li><a href="<?php echo url('option'); ?>">添加检测单</a></li>-->
    </ul>
</div>
<div class="demoTable" style="margin-top: 25px;margin-left:20px;">
    建单时间：
    <div class="layui-inline">
        <input type="text" class="layui-input" id="start_time" name="start_time" placeholder="yyyy-MM-dd HH:mm:ss">
    </div>
    -
    <div class="layui-inline">
        <input type="text" class="layui-input" id="end_time" name="end_time" placeholder="yyyy-MM-dd HH:mm:ss">
    </div>
    二维码：
    <div class="layui-inline" style="width:360px;">
        <input class="layui-input" name="like" id="like" placeholder="防伪码、流水号" autocomplete="off">
    </div>
    核销人：
    <div class="layui-inline">
        <form class="layui-form">
            <select class="layui-input" name="staff_id" id="staff_id" lay-filter="staff_id">
                <option value="">请选择核销人</option>
                <?php foreach($staff as $vo): ?>
                <option value="<?php echo htmlentities($vo['id']); ?>"><?php echo htmlentities($vo['name']); ?></option>
                <?php endforeach; ?>
            </select>
        </form>
    </div>
    <br>
    <br>

     产品：
    <div class="layui-inline">
		<form class="layui-form">
			<select class="layui-input" name="goods_id" id="goods_id" lay-filter="goods_id">
				<option value="">请选择产品</option>
				<?php foreach($goods as $vo): ?>
				<option value="<?php echo htmlentities($vo['id']); ?>"><?php echo htmlentities($vo['title']); ?></option>
				<?php endforeach; ?>
			</select>
		</form>
    </div>
    业务员：
    <div class="layui-inline">
        <form class="layui-form">
            <select class="layui-input" name="customer_id" id="customer_id" lay-filter="customer_id">
                <option value="">请选择业务员：</option>
                <?php foreach($customer as $vo): ?>
                <option value="<?php echo htmlentities($vo['id']); ?>"><?php echo htmlentities($vo['customer_name']); ?></option>
                <?php endforeach; ?>
            </select>
        </form>
    </div>

    <button class="layui-btn" data-type="reload"> 搜索</button>
</div>
<div class="layui-card-body">
    <div data-model="table-bind">
        <table class="layui-hide" id="data_table" lay-filter="data_table" data-table></table>
    </div>
</div>
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-group">

      </div>
</script>

<script type="text/html" id="image">
    <img src="{{d.image}}" height="30">
</script>



			</div>
		</div>
	</div>
</div>


<script type="text/javascript">
var webRoot = "<?php echo request()->root(true); ?>/";
var webControl = "<?php echo request()->controller(); ?>";
Do.ready('common',function(){ base.frame(); });
</script>

<script type="text/javascript">
    var mixin = {};
    var SlefUrl = this.location.href;
   
    layui.use(['table','laydate'], function(){
        var table = layui.table;
        var laydate = layui.laydate;
        table.on('checkbox(demo)', function(obj){
            console.log(obj)
        });
        table.render({
            elem: '#data_table',
            url:SlefUrl,
            limit:10,
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
            title: '导出Excel'
            ,layEvent: 'LAYTABLE_Excel'
            ,icon: 'layui-icon layui-icon-export'
            }],
            // cellMinWidth: 70,
            
            cols: [[
                {type: 'checkbox'}
                ,{field:'id', title: 'id', width:80, sort: true,align:'left'}
                ,{field:'staff_name', title: '核销人姓名', width:150, sort: true,align:'left'}
                ,{field:'order_sn', title: '二维码', width:200, sort: true,align:'left'}
                ,{field:'code', title: '流水号', width:100, sort: true,align:'left'}
                ,{field:'goods_title', title: '产品名称', sort: true,align:'left'}
                ,{field:'good_sn', title: '产品编号', sort: true,align:'left'}
                ,{field:'customer_name', title: '业务员名称',  sort: true,align:'left'}
                ,{field:'create_time', title: '核销时间', sort: true,align:'left'}
                // ,{field:'remark', title: '备注', sort: true,align:'left'}
                
                // ,{field:'op', title: '操作',toolbar: '#barTar',width:300,align:'center',fixed: 'right'}
            ]],
            page: true,
            id: 'testReload'
        });

        //日期时间选择器
        laydate.render({
            elem: '#start_time'
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#end_time'
            ,type: 'datetime'
        });

        //头工具栏事件
        table.on('toolbar(data_table)', function(obj){
            
            if(obj.event === 'LAYTABLE_Excel'){
                var result = {};
                result.customer_id = $('#customer_id').val();
                result.goods_id = $('#goods_id').val();
                result.staff_id = $('#staff_id').val();
                result.like = $('#like').val();
                result.start_time = $('#start_time').val();
                result.end_time = $('#end_time').val();

                DownLoadFile({'url':''+webRoot+ webControl+'/load_excel','data':result})
            }
            
        });
        table.on('tool(data_table)', function(obj) {
            var data = obj.data;
            data.table = "order";
            if (obj.event === 'del') {
                layer.confirm('确定删除吗？', function (index) {
                    layer.close(index);
                    form.formDel(data, obj);
                });
            }
        })
            
        var $ = layui.$, active = {
            reload: function(){
                var customer_id = $('#customer_id');
                var goods_id = $('#goods_id');
                var staff_id = $('#staff_id');
                var like = $('#like');
                var start_time = $('#start_time');
                var end_time = $('#end_time');

                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        customer_id: customer_id.val(), goods_id: goods_id.val(),staff_id:staff_id.val(),like:like.val(),start_time:start_time.val(),end_time:end_time.val()
                    }
                }, 'data');
            }

            // 批量删除
            ,getDelData: function(){ 
                //获取选中数目

                var checkStatus = table.checkStatus('testReload')
                ,data = checkStatus.data;
                var  id = [];
                for( var i in data){
                    id.push(data[i]['id']);
                }
                if( id.length > 0 ){
                    var result = {};
                    result.id = id;
                    layer.confirm('确定删除选中表单吗？', function(index){
                        $.post(webRoot+ webControl+'/delArr',result,function(res){
                            layer.alert(res.msg);
                            if( res.code ){
                                setInterval(function(){
                                    location.reload();
                                },1000)
                            }
                        })
                    })

                }else{
                    layer.alert('请先选择检测单');
                }
                

            }
        };

		
        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
		
		//tableHBtnJd
		$('body').on('click', '.tableHBtn',function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        var DownLoadFile = function (options) {
            var config = $.extend(true, { method: 'post' }, options);
            var $iframe = $('<iframe id="down-file-iframe" />');
            var $form = $('<form target="down-file-iframe" method="' + config.method + '" />');
            $form.attr('action', config.url);
            for (var key in config.data) {
                $form.append('<input type="hidden" name="' + key + '" value="' + config.data[key] + '" />');
            }
            $iframe.append($form);
            $(document.body).append($iframe);
            $form[0].submit();
            $iframe.remove();
        }
        
        function downloadIamge(imgsrc,name){
            let image = new Image();
            // 解决跨域 Canvas 污染问题
            image.setAttribute("crossOrigin", "anonymous");
            image.onload = function() {
                let canvas = document.createElement("canvas");
                canvas.width = image.width;
                canvas.height = image.height;
                let context = canvas.getContext("2d");
                context.drawImage(image, 0, 0, image.width, image.height);
                let url = canvas.toDataURL("image/png"); //得到图片的base64编码数据
                let a = document.createElement("a"); // 生成一个a元素
                let event = new MouseEvent("click"); // 创建一个单击事件
                a.download = name || "photo"; // 设置图片名称
                a.href = url; // 将生成的URL设置为a.href属性
                a.dispatchEvent(event); // 触发a的单击事件
            };
            image.src = imgsrc;
        }

    });
</script>

</body>
</html>